
<?php
$contextMenu[0]["link"]      = "javascript:fn_nuevo()";
$contextMenu[0]["linkIcon"]  = "application_add.png";
$contextMenu[0]["linkTitle"] = "Nueva recepcion";


$codigoBusqueda = "";
$nombreBusqueda = "";

if (array_key_exists('codigo', $_POST)) {
	$codigoBusqueda = $_POST["codigo"];
}elseif (array_key_exists('codigoBusqueda', $_POST)) {
	$codigoBusqueda = $_POST["codigoBusqueda"];
}

if (array_key_exists('nombre', $_POST)) {
	$nombreBusqueda = $_POST["nombre"];
}elseif (array_key_exists('nombreBusqueda', $_POST)) {
	$nombreBusqueda = $_POST["nombreBusqueda"];
}

?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
fn_nuevo = function fn_nuevo()
{
	$("#zonaContenedor").load("/gourmet-express/trunk/src/index.php?do=OrdenIngreso&accion=nuevo", function(){
	
	});
}; 

fn_guardar = function ()
{
		var guardar = confirm("Desea guardar los datos...?")
    if ( guardar ) 
    {
		  var str=$("#form_nuevo").serialize();
			$.ajax({
				url:'/gourmet-express/trunk/src/index.php?do=OrdenIngreso&accion=guardarSave',
				data:str,
				type:'get',
				dataType: "json",
				success:function (data){
				        if(data.rpta=='true')
				        {
					       fn_editar(data.rcpId);
				        }else{
				            alert(data.msg);
				        }
						}
				   });
     }
};

		
fn_editar = function(rcpId)
{			
   $("#zonaContenedor").load("/gourmet-express/trunk/src/index.php?do=OrdenIngreso&accion=editar&rcpId="+rcpId, function(){
   	
   });
}
	
fn_actualizar =function(){
	var actualizar = confirm("Desea actualizar los datos ..?")
	if ( actualizar ) {
  	var str=$("#form_editar").serialize();
  	$.ajax({
  		url:'/gourmet-express/trunk/src/index.php?do=OrdenIngreso&accion=editarSave',
  		data:str,
  		type:'get',
  		dataType: "json",
  				success:function (data){
  				        if(data.rpta=='true')
  				        {
  					    fn_editar(data.rcpId);
  				        }else{
  				            alert(data.msg);
  				        }
  						}
  				   });
	}
 };
	      		
fn_eliminar = function (pro_eli,tr_id)
{
};

fn_cerrar =function(){
	var actualizar = confirm("Desea ingresar la recepcion al stock. ?")
	if ( actualizar ) {
         var str=$("#form_editar").serialize();
         alert('x');
         $.ajax({
              url:'/gourmet-express/trunk/src/index.php?do=OrdenIngreso&accion=cerrar',
              data:str,
              type:'get',
              dataType: "json",
                        success:function (data){
                                if(data.rpta=='true')
                                {
                                    fn_editar(data.rcpId);   
                                }else{
                                    alert(data.msg);
                                }
                       }
          });
	}
 };

</script>
<body>
<div id="main">
  <?php include $_SERVER['DOCUMENT_ROOT'].'/gourmet-express/trunk/src/views/header.inc'; ?>
  <div id="zonaContenedor">
    <h3>.:: Orden de Ingreso </h3>
    <div>

	<form id='formRecepcion' name='formRecepcion' method="post" >    
		Nro : <input type="text" name="stockIngresoId" size="15">
		<input type="submit" name="aceptar" value="aceptar" >    
	</form>         
	
		<table id="flex1" style="display:none"></table>
		<script type="text/javascript">
		$("#flex1").flexigrid({
			url: '/gourmet-express/trunk/src/index.php?do=StockIngreso&accion=contenedor',
			dataType: 'json',
			colModel : [
				{display: 'Rcp Id', name : 'RcpId', width : 50, sortable : true, align: 'left'},
                                {display: 'Tipo ingreso', name : 'Tipo', width : 75, sortable : true, align: 'left'},
				{display: 'Almacen', name : 'AlmId', width : 70, sortable : true, align: 'left', hide: false},
                                {display: 'Doc Ingreso', name : 'DocIngresoNum', width : 75, sortable : true, align: 'left'},                       
				{display: 'Proveedor', name : 'ProveedorNombre', width : 200, sortable : true, align: 'left'},
				{display: 'Fecha Ingreso', name : 'FechaIngreso', width : 75, sortable : true, align: 'left'},
                                {display: 'Estado', name : 'Estado', width : 75, sortable : true, align: 'left'},
				{display: '&nbsp;', name : 'opciones', width : 45, sortable : true, align: 'right'}
				],
			searchitems : [
				{display: 'Rcp Id', name : 'RcpId'}
				],
			sortname: "RcpId",
			sortorder: "asc",
			usepager: true,
			title: 'Recepcion',
			useRp: true,
			rp: 15,
			showTableToggleBtn: true,
			width: 800,
			onSubmit: addFormData,
			height: 300
		});   
		
		
		//This function adds paramaters to the post of flexigrid. You can add a verification as well by return to false if you don't want flexigrid to submit			
		function addFormData(){
			//passing a form object to serializeArray will get the valid data from all the objects, but, if the you pass a non-form object, you have to specify the input elements that the data will come from
			var dt = $('#formRecepcion').serializeArray();
			$("#flex1").flexOptions({params: dt});
			return true;
		}
			
		$('#formRecepcion').submit(function (){
			$('#flex1').flexOptions({newp: 1}).flexReload();
			return false;
		});
		</script>
	</div>
	<div id="div_listar" align="center"></div>
	<div id="div_oculto" style="display: none;"></div>
</div>        
</body>
<script>
//fn_buscar();
</script>